//
//  ChartPicColor.m
//  Daybook
//
//  Created by dllo on 16/6/4.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "ChartPicColor.h"

@interface ChartPicColor ()



@end
@implementation ChartPicColor

+ (NSMutableArray *)incomeColorArrByNameArr:(NSMutableArray *)nameArr {
    NSMutableArray *indexArr = [NSMutableArray array];
    NSMutableArray *colorArr = [NSMutableArray array];
    
    NSArray *originIncomeColor = @[@234, @128, @16, @235, @79, @56, @235, @79, @56, @235, @79, @56, @244, @198, @0, @234, @128, @16, @235, @79, @56, @221, @101, @114];
    
    NSArray *orginIncomeName = [NSMutableArray arrayWithObjects:@"一般", @"报销", @"工资", @"红包", @"兼职", @"奖金", @"投资", @"其他", nil];
    
    for (NSInteger i = 0; i < nameArr.count; i++) {
        NSString *nameStr = nameArr[i];
        for (NSInteger j = 0; j < orginIncomeName.count; j++) {
            NSString *originNameStr = orginIncomeName[j];
            if ([nameStr isEqualToString:originNameStr]) {
                [indexArr addObject:[NSString stringWithFormat:@"%ld", j]];
            }
        }
    }
    
    for (NSInteger i = 0; i < indexArr.count; i++) {
        NSString *indexStr = indexArr[i];
        NSInteger index = indexStr.integerValue;
        UIColor *bgColor = [UIColor colorWithRed:[originIncomeColor[3 * index] floatValue] /255.0 green:[originIncomeColor[3 * index + 1] floatValue] /255.0 blue:[originIncomeColor[3 * index + 2] floatValue] /255.0 alpha:1];
        [colorArr addObject:bgColor];
    }
    return colorArr;
}

+ (NSMutableArray *)payColorArrByNameArr:(NSMutableArray *)nameArr {
    NSMutableArray *indexArr = [NSMutableArray array];
    NSMutableArray *colorArr = [NSMutableArray array];
    
    NSArray *originPayColor = @[@127, @184, @14,
                                @88, @94, @170,
                                @245, @130, @32,
                                @51, @71, @95,
                                @234, @102, @166,
                                @235, @79, @56,
                                @0, @154, @214,
                                @234, @128, @16,
                                @80, @183, @193,
                                @157, @85, @184,
                                @69, @185, @124,
                                @86, @171, @228,
                                @86, @69, @45,
                                @235, @79, @56,
                                @0, @187, @156,
                                @86, @171, @228,
                                @157, @85, @184,
                                @234, @128, @16, @252, @39, @28];
    NSArray *originPayName = [NSMutableArray arrayWithObjects:@"一般", @"用餐", @"交通", @"服饰", @"丽人", @"日用品", @"娱乐", @"食材", @"零食", @"酒水", @"住房", @"通讯", @"家居", @"人情", @"学习", @"医疗", @"旅游", @"数码", @"其他", nil];
    for (NSInteger i = 0; i < nameArr.count; i++) {
        NSString *nameStr = nameArr[i];
        for (NSInteger j = 0; j < originPayName.count; j++) {
            NSString *originNameStr = originPayName[j];
            if ([nameStr isEqualToString:originNameStr]) {
                [indexArr addObject:[NSString stringWithFormat:@"%ld", j]];
            }
        }
    }
    
    for (NSInteger i = 0; i < indexArr.count; i++) {
        NSString *indexStr = indexArr[i];
        NSInteger index = indexStr.integerValue;
        UIColor *bgColor = [UIColor colorWithRed:[originPayColor[3 * index] floatValue] /255.0 green:[originPayColor[3 * index + 1] floatValue] /255.0 blue:[originPayColor[3 * index + 2] floatValue] /255.0 alpha:1];
        [colorArr addObject:bgColor];
    }
    return colorArr;
}

@end
